<style type="text/css">
div.lmenudiv{
border:1px solid #CCCCCC;
position:relative;
width:120px;
}
div.lmenudiv a{
display:block;
padding:10px;
text-decoration:none;
text-align:center;
background-color:#F7FAFF;
color:#666666;
}
div.lmenudiv a.on,div.lmenudiv a:hover{
background-color: #E8F0FF !important;
color: #222222 !important;
text-decoration: none;
}
</style>

<script type="text/javascript">
var orderstatus = '<?PHP if(isset($orderstatus)) echo $orderstatus; else echo ''; ?>';
var url_list = '/admin_order/list';
var url_view = '/admin_order/view';

$().ready(function(){
	showLoading();
	o2js.build('ymprompt'); 
	o2js.build('jscalendar');
	o2js.build('dates');
	fnSetSltDate('b_date','b_date_slt')
	fnSetSltDate('e_date','e_date_slt')
	$('#b_date').val('');
	$('#e_date').val('');
	
	
	fnSetSltDate('rec_bdate','rec_bdate_slt')
	fnSetSltDate('rec_edate','rec_edate_slt')
	$('#rec_bdate').val('');
	$('#rec_edate').val('');
	
	
	
	
	fnLoadOptNum();
	
});

/* 查询 */
function fnSearchs(){
	grids.setBaseParams({
		keywords:encodeURIComponent($('#keywords').val()), 
		b_date:$('#b_date').val(),
		e_date:$('#e_date').val(),
		rec_bdate:$('#rec_bdate').val(),
		rec_edate:$('#rec_edate').val(),
		sendtime:$('#sendtime').val(),
		status:orderstatus
	}); 
	grids.load(1); 
}
/* 预定义日期 */
function fnSearchDate(){
	$('#s_date_div').hide();
	var date = new Date();
	switch($('#senddate').val()){
		case "0"://  
			$('#b_date').val('');
			$('#e_date').val('');
			fnSearchs();
			break;
		case "1"://  
			$('#b_date').val(today());
			$('#e_date').val(today());
			fnSearchs();
			break;
		case "2":// 
			var b = getWeekFirst(date).eformat('yyyy-MM-dd');
			var e = getWeekLast(date).eformat('yyyy-MM-dd'); 
			$('#b_date').val(b);
			$('#e_date').val(e);
			fnSearchs();
			break;
		case "3"://本月
			var b = getMonthFirst(date).eformat('yyyy-MM-dd');
			var e = getMonthLast(date).eformat('yyyy-MM-dd'); 
			$('#b_date').val(b);
			$('#e_date').val(e);
			fnSearchs();
			break;
		default:
			var b = getMonthFirst(date).eformat('yyyy-MM-dd');
			var e = getMonthLast(date).eformat('yyyy-MM-dd'); 
			$('#b_date').val(b);
			$('#e_date').val(e);
			$('#s_date_div').show();
			break;
	}
}  
 
function fnRecDate(){
	$('#s_slt_rec_date').hide();
	var date = new Date();
	switch($('#slt_rec_date').val()){
		case "0"://  
			$('#rec_bdate').val('');
			$('#rec_edate').val('');
			fnSearchs();
			break;
		case "1"://  
			$('#rec_bdate').val(today());
			$('#rec_edate').val(today());
			fnSearchs();
			break;
		case "2"://  
			$('#rec_bdate').val(addDay(new Date(),1).eformat('yyyy-MM-dd'));
			$('#rec_edate').val(addDay(new Date(),1).eformat('yyyy-MM-dd'));
			fnSearchs();
			break;
		case "3":// 
			var b = getWeekFirst(date).eformat('yyyy-MM-dd');
			var e = getWeekLast(date).eformat('yyyy-MM-dd'); 
			$('#rec_bdate').val(b);
			$('#rec_edate').val(e);
			fnSearchs();
			break;
		case "4"://本月
			var b = getMonthFirst(date).eformat('yyyy-MM-dd');
			var e = getMonthLast(date).eformat('yyyy-MM-dd'); 
			$('#rec_bdate').val(b);
			$('#rec_edate').val(e);
			fnSearchs();
			break;
		default:
			var b = getMonthFirst(date).eformat('yyyy-MM-dd');
			var e = getMonthLast(date).eformat('yyyy-MM-dd'); 
			$('#rec_bdate').val(b);
			$('#rec_edate').val(e);
			$('#s_slt_rec_date').show();
			break;
	}
}


/* 加载各个数量 */
function fnLoadOptNum(){
	$.post(
		'/admin_order/loadorder_num',
		{
		},
		function(e){
			var ok = errorHandler(e);
			if(ok && ok.success=="1"){
				$('#order_all_span').html('('+ok.order_all+')');
				$('#order_cancel2_span').html('('+ok.order_cancel2+')');
				$('#order_cancel1_span').html('('+ok.order_cancel1+')');
				$('#order_1_span').html('('+ok.order_1+')');
				$('#order_2_span').html('('+ok.order_2+')');
				$('#order_3_span').html('('+ok.order_3+')');
				$('#order_4_span').html('('+ok.order_4+')');
			}
		}
	);
}
/* 加载不同的状态 */
function fnLoadOrderStatus(s){
	orderstatus = s;
	fnSearchs();
	
	$('.a_order_num').removeClass('on');
	switch(s){
		case "":
			$('#order_a_all').addClass('on');
			break;
		case "1":
			$('#order_a_1').addClass('on');
			break;
		case "2":
			$('#order_a_2').addClass('on');
			break;
		case "3":
			$('#order_a_3').addClass('on');
			break;
		case "4":
			$('#order_a_4').addClass('on');
			break;
		case "-2":
			$('#order_a_cancel2').addClass('on');
			break;
		default:
			$('#order_a_cancel1').addClass('on');
			break;
			break;
	}
}

</script>	
<table style="border-collapse:collapse;width:100%;border:0px solid #CCCCCC;">
	<tr>
		<td style="width:15%;vertical-align:top;text-align:left">
			<div class="lmenudiv">
				<a href="javascript:void(0)" onclick="fnLoadOrderStatus('')" class="a_order_num <?PHP if(!isset($orderstatus) || $orderstatus=="") echo 'on'; ?>"  id="order_a_all">全部订单<span id="order_all_span" class="red">()</span></a>
				<a href="javascript:void(0)" onclick="fnLoadOrderStatus('1')" class="a_order_num <?PHP if(isset($orderstatus) && $orderstatus=="1") echo 'on'; ?>"  id="order_a_1">待审核<span id="order_1_span" class="red">()</span></a>
				<a href="javascript:void(0)" onclick="fnLoadOrderStatus('2')" class="a_order_num <?PHP if(isset($orderstatus) && $orderstatus=="2") echo 'on'; ?>"  id="order_a_2">已审核，待生产<span id="order_2_span" class="red">()</span></a>
				<a href="javascript:void(0)" onclick="fnLoadOrderStatus('3')" class="a_order_num <?PHP if(isset($orderstatus) && $orderstatus=="3") echo 'on'; ?>"  id="order_a_3">已生产，待配送<span id="order_3_span" class="red">()</span></a>
				<a href="javascript:void(0)" onclick="fnLoadOrderStatus('4')" class="a_order_num <?PHP if(isset($orderstatus) && $orderstatus=="4") echo 'on'; ?>"  id="order_a_4">已配送<span id="order_4_span" class="red">()</span></a>
				<a href="javascript:void(0)" onclick="fnLoadOrderStatus('-2')" class="a_order_num <?PHP if(isset($orderstatus) && $orderstatus=="-2") echo 'on'; ?>"  id="order_a_cancel2">系统取消<span id="order_cancel2_span" class="red">()</span></a>
				<a href="javascript:void(0)" onclick="fnLoadOrderStatus('-1')" class="a_order_num <?PHP if(isset($orderstatus) && $orderstatus=="-1") echo 'on'; ?>"  id="order_a_cancel1">用户取消<span id="order_cancel1_span" class="red">()</span></a>
			</div>
		</td>
		<td style="width:85%;vertical-align:top;text-align:left">